#include <mainwindow.h>
#include <ui_mainwindow.h>
#include <QRect>
#include <QPixmap>
#include <QPainter>
#include <QFont>
#include <QKeyEvent>
#include <QMainWindow>
#include <cgamemap.h>
#include <roleman.h>
#include <monster.h>



MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    DrawBackground();
    DrawMap(map);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::keyPressEvent(QKeyEvent *event){
    hero.HeroMove(map,event);
}


/*void magic_tower::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QFont font1("Courier",30);
    painter.setFont(font1);
    const QRect rectangle = QRect(400, 200,1000,1000);
    QRect boundingRect;


    //背景
    painter.setPen(Qt::black);
    painter.setBrush(Qt::gray);
    painter.drawRect(350,120,550,550);
    //格子
    painter.setPen(Qt::black);
    for(int i=1;i<=10;i++)
    {
        painter.drawLine(350,120+i*50,900,120+i*50);
    }
    for(int i=1;i<=10;i++)
    {
        painter.drawLine(350+i*50,120,350+i*50,670);
    }
    //画勇者
    painter.setPen(Qt::black);
    painter.setBrush(Qt::green);
    painter.drawRect(pos);

    painter.setFont(font1);
    painter.setPen(Qt::darkRed);
    painter.setBrush(Qt::darkRed);
    painter.drawText(300+posy*50,120+posx*50,name);
    //画墙
}*/
